package com.lmonkey.servlet.comment;

import com.lmonkey.servic.COMMENTDao;
import com.lmonkey.shop.COMMENT;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;
import java.io.PrintWriter;

@MultipartConfig
@WebServlet("/admin/admin_docommentupdate")
public class DoCommentUpdate extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        //获取数据
        String desc = request.getParameter("pl");
        int id = Integer.parseInt(request.getParameter("id"));
        String user = request.getParameter("user");

        //获取part对象
        Part part = request.getPart("photo");
        String filename = part.getSubmittedFileName();

        //进行修改评论
        COMMENTDao.updateBy(desc,id,filename);

        response.sendRedirect("admin_commentselect?cp="+request.getParameter("cpage")+"&keywords="+request.getParameter("keywords"));

    }
}
